'''
Data classes for modules
'''

from PyQt4 import QtCore
import os
from rgeSystem import *
from rgeSave import *
import rgeScene
import rgeBase
import rgeExtra

#standard keys
STARTING_SCENE_KEY = "_starting_scene"
MAIN_SCRIPT_KEY = "_main_script"


#standard indexes
#scenes
STARTING_SCENE_INDEX = 0
#scripts
MAIN_SCRIPT_INDEX = 0


class ModuleData(rgeBase.BaseData):
    def __init__(self, NewName = "No_Name"):
        super(ModuleData, self).__init__(NewName)
        self.addStandard(rgeExtra.SceneItem("", STARTING_SCENE_KEY, STARTING_SCENE_INDEX))
        self.addStandard(rgeExtra.ScriptItem("", MAIN_SCRIPT_KEY, MAIN_SCRIPT_INDEX))

        self.setFilename(NewName + MODULE_EXTENSION)

    def setStartingScene(self, NewScene):
        if NewScene:
            self.getStandard(STARTING_SCENE_KEY).setValue(NewScene)
        self.edited()

    def getStartingScene(self):
        return self.getStandard(STARTING_SCENE_KEY).getValue()

    def setPythonScript(self, Script):
        if Script:
            self.getStandard(MAIN_SCRIPT_KEY).setValue(Script)
        self.edited()

    def getPythonScript(self):
        return self.getStandard(MAIN_SCRIPT_KEY).getValue()

    def setFilename(self, NewName):
        self.Filename = os.path.basename(NewName)